#include <iostream>

using namespace std;

int cmmdc(int, int);

int main()
{
    int a[100];
    int n,i,j,k;
    std::cout<<"n=";
    std::cin>>n;
    for (i=0;i<n;i++)
    {
        std::cout<<"a["<<i<<"]=";
        std::cin>>a[i];
    }
    std::cout<<"k=";
    std::cin>>k;
    j=0;
     for (i=0;i<n;i++)
    {

        if (cmmdc(a[i],k)==1)
        {std::cout<<a[i]<<" este prim cu "<<k<<endl;
        j=j++;
        }

    }
    if (j==0) std::cout<<"nu sunt elemente care indeplinesc criteriile";

    return 0;
}

int cmmdc(int x, int y)
{
    while (x!=y)
   {
       if (x>y) x=x-y;
       else y=y-x;
   }
    return x;
}
